﻿using Microsoft.Extensions.DependencyInjection;
using RotovapPlatform.Domain.Equipment.Interfaces.Services;
using RotovapPlatform.Application.Services;
using RotovapPlatform.Domain.Services.DeviceParameters;
using RotovapPlatform.Application.Services.Scheduling;
using RotovapPlatform.Domain.Services.Scheduling;
using RotovapPlatform.Application.Services.Experiments;
using RotovapPlatform.Domain.Services.Experiments;
using RotovapPlatform.Application.Services.Devices;
using RotovapPlatform.Domain.Services.Devices;
using RotovapPlatform.Application.Services.Storages;
using RotovapPlatform.Domain.Recipes.Services;
using RotovapPlatform.Domain.Services.Storages;
using RotovapPlatform.Domain.Services.Data;
using RotovapPlatform.Application.Services.Data;
using RotovapPlatform.Infrastructure.Data.Services;
using RotovapPlatform.Domain.Equipment.Device.IO;


namespace RotovapPlatform.Application.DependencyInjection
{
	public static class ApplicationModule
	{
		public static IServiceCollection AddApplicationServices(this IServiceCollection services)
		{
			//Devices
			// 注册设备管理器
			services.AddSingleton<IDeviceManager, DeviceManager>();
			// 注册设备状态服务
			services.AddSingleton<IDeviceStatusService, DeviceStatusService>();
			// 注册设备应用服务
			services.AddScoped<IDeviceAppService, DeviceAppService>();
			// 注册设备领域服务
			services.AddScoped<IDeviceDomainService, DeviceDomainService>();


			//Experiments
			//注册应用层实验流程服务
			services.AddScoped<IExperimentProcessAppService, ExperimentProcessAppService>();
			//注册领域层实验流程服务
			services.AddScoped<IExperimentProcessDomainService, ExperimentProcessDomainService>();
			//注册实验流程协调器（替代原来的后台服务）
			services.AddSingleton<IExperimentProcessCoordinator, ExperimentProcessCoordinator>();

			//Recipes
			//注册应用层配方服务
			services.AddScoped<IRecipeAppService, RecipeAppService>();
			//注册领域层配方服务
			services.AddScoped<IRecipeDomainService, RecipeDomainService>();


			//Scheduling
			//注册应用层任务调度服务
			services.AddScoped<ITaskSchedulingAppService, TaskSchedulingAppService>();
			//注册领域层任务调度服务
			services.AddScoped<ITaskSchedulingDomainService, TaskSchedulingDomainService>();


			//Storages
			//注册应用层存储服务
			services.AddScoped<IStorageAppService, StorageAppService>();
			//注册领域层存储服务
			services.AddScoped<IStorageDomainService, StorageDomainService>();


			//Data
			//注册应用层数据记录服务
			services.AddScoped<IDataRecordingAppService, DataRecordingAppService>();
			//注册领域层数据记录服务
			services.AddScoped<IDataRecordingDomainService, DataRecordingDomainService>();



			//注册设备参数领域服务
			services.AddScoped<IDeviceParameterDomainService, DeviceParameterDomainService>();



			// 注册IO模块服务
			services.AddSingleton<IIOSignalManager, IOSignalManager>();
			services.AddSingleton<IIOSignalAppService, IOSignalAppService>();



			return services;
		}
	}
}